//
//  MKTFuncItemTableViewCell.m
//  MKUI
//
//  Created by sushangjin on 2020/6/1.
//Copyright © 2020 sushangjin. All rights reserved.
//

#import "MKTFuncItemTVCell.h"
#import "MKTFuncItem.h"
@interface MKTFuncItemTVCell ()
@property(nonatomic,strong) MKUIFlowLayoutButton *button;
@property(nonatomic,strong) MKUIFlowLayoutConstraint *flowlayout;
@end

@implementation MKTFuncItemTVCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
	if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.nameLabel = [[UILabel alloc] init];
        self.nameLabel.numberOfLines = 0;
        self.nameLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.nameLabel];
        //
        self.flowlayout = [[MKUIFlowLayoutConstraint alloc] initWithItems:@[self.nameLabel] constraintParam:(MKUIFlowLayoutConstraintParam_H_C_L) contentInsets:UIEdgeInsetsMake(10, 20, 10, 10) interitemSpacing:10];
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
	}
	return self;
}
- (void)customLayoutSubviews{
    [super customLayoutSubviews];
    CGRect bounds = self.contentView.bounds;
    self.flowlayout.bounds = bounds;
    [self.flowlayout layoutItemsWithResizeItems:YES];
}
- (CGSize)customSizeThatFits:(CGSize)size{
    return [self.flowlayout sizeThatFits:size resizeItems:YES];
}
- (void)customReloadCellModel{
	[super customReloadCellModel];
	MKTFuncItem *modelObject = self.cellModel.modelValue;
    self.nameLabel.text = modelObject.name;
}
@end
